//
//  BuyRoseViewController.m
//  ROSE
//
//  Created by 艾阳 on 2018/6/5.
//  Copyright © 2018年 HeNanZhongDunYunAn. All rights reserved.
//

#import "BuyRoseViewController.h"
#import "ThreeInputView.h"

@interface BuyRoseViewController ()
@property (nonatomic,strong) ThreeInputView *inputView;
@end

@implementation BuyRoseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"购买";
    [self setInputView];
}


/**
 设置输入区域
 */
- (void)setInputView{
    self.inputView = [[ThreeInputView alloc]init];
    [self.view addSubview:self.inputView];
    [self.inputView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(300);
        make.top.mas_equalTo(20);
    }];
    
    [self.inputView setTitle:@[@"解锁密码",@"验证码",@""] PlaceHolder:@[@"请输入解锁密码",@"请输入验证码",@""]];
    self.inputView.textField3.hidden = YES;
    [self.inputView setCountDownInTextfield:self.inputView.textField2];
}

/**
 确认购买
 */
- (void)setBuyButton{
    UIButton *sureBtn = [[UIButton alloc]init];
    sureBtn.backgroundColor = [UIColor themeColor];
    sureBtn.titleLabel.textColor = [UIColor whiteColor];
    [sureBtn setTitle:@"确认购买" forState:UIControlStateNormal];
    [sureBtn.titleLabel setFont:[UIFont systemFontOfSize:15]];
    sureBtn.layer.masksToBounds = YES;
    sureBtn.layer.cornerRadius = 20.0f;
    [self.view addSubview:sureBtn];
    [sureBtn addTarget:self action:@selector(buyAction) forControlEvents:UIControlEventTouchUpInside];
    
    [sureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(35);
        make.right.mas_equalTo(-35);
        make.bottom.mas_equalTo(-20);
        make.height.mas_equalTo(40);
    }];
}

- (void)buyAction{
    if (LMJIsEmpty(self.inputView.textField1.text)) {
        /**请输入解锁密码 */
    }else if(LMJIsEmpty(self.inputView.textField2.text)){
        /**请输入验证码 */
    }else{
        [[LMJRequestManager sharedManager] POST:[NSString stringWithFormat:@"%@/market/buy",url_base] parameters:@{@"ROSEID":@"123",@"PWD":self.inputView.textField1.text,@"YZM":self.inputView.textField2.text} completion:^(LMJBaseResponse *response) {
            
        }];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
